﻿using MediatR;
using Product.API.Applcation.Command.ProductTypeInfo;
using Product.Domain;
using Product.Infrstructre.Impl;

namespace Product.API.Applcation.CommandHandlers.ProductTypeInfo
{
    /// <summary>
    /// 产品分类修改
    /// </summary>
    public class ProductUpdateCommandHandler : IRequestHandler<ProductUpdateCommand, int>
    {
        protected readonly IbaseProductRepository ibase;

        public ProductUpdateCommandHandler(IbaseProductRepository ibase)
        {
            this.ibase = ibase;
        }
        /// <summary>
        /// 修改产品分类信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> Handle(ProductUpdateCommand request, CancellationToken cancellationToken)
        {
         
                //存在产品信息，修改产品信息
                return await ibase.UpdateAsync(new Domain.ProductType() { ProductTypeID = request.ProductTypeID, ProductTypeCode = request.ProductTypeCode, ProductTypeName = request.ProductTypeName, ParentId = request.ParentId, Premark = request.Premark, UpdName = request.UpdName, UpdTime = DateTime.Now, CreateTime = request.CreateTime, AddName = request.AddName, AddTime = request.AddTime,Office_Id = request.Office_Id });
            
        }
    }
}
